<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        .box {
            width: 100px;
            height: 100px;
            margin: 10px auto;
        }
        .task {
            width: 100vw;
            height: 100vh;
            background-color: rgba(0, 0, 0, 0.6);
            position: fixed;
            top: 0;
            left: 0;
            display: none;
        }
        .mask {
            width: 400px;
            height: 240px;
            background-color: skyblue;
            margin: 20% auto;
            border: 5px solid sandybrown;
            box-sizing: border-box;
        }
        .top {
            width: 100%;
            height: 25px;
            background-color: rgb(255, 187, 0);
            border-bottom: 5px solid sandybrown;
            position: relative;
        }
        .top p {
            width: 20px;
            height: 20px;
            background-color: #fff;
            text-align: center;
            position: absolute;
            right: 2px;
            top: 2px;
        }
    </style>
</head>
<body>
    <div class="box">
    <button class="btn">弹出层</button>
    </div>
     <div class="task">
        <div class="mask">
            <div class="top">
                <p class="pp">×</p>
            </div>
        </div>
    </div>
</body>
<script>
    var btn = document.querySelector('.btn')
    var task = document.querySelector('.task')
    var pp = document.querySelector('.pp')
    btn.onclick = function () {
        task.style.display = 'block'
    }
    pp.onclick = function () {
        task.style.display = 'none'
    }
</script>
</html>